<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8"/>
		<title>RcPtr.alloc - multiple declarations</title>
		<link rel="stylesheet" type="text/css" href="../../styles/ddox.css"/>
		<link rel="stylesheet" href="../../prettify/prettify.css" type="text/css"/>
		<script type="text/javascript" src="../../scripts/jquery.js">/**/</script><script type="text/javascript" src="../../scripts/ddox.js">/**/</script>
	</head>
	<body onload="setupDdox();">
		<nav id="main-nav">
			<noscript>
				<p style="color: red">The search functionality needs JavaScript enabled</p>
			</noscript>
			<div id="symbolSearchPane" style="display: none">
				<form action="#" method="GET">
					<input id="symbolSearch" type="text" name="q" placeholder="Search for symbols" autocomplete="off" onchange="performSymbolSearch(40);" onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"/>
				</form>
				<ul id="symbolSearchResults" class="symbolList" style="display: none"></ul><script type="application/javascript" src="../../symbols.js"></script><script type="application/javascript">var symbolSearchRootDir = "../../";
$('#symbolSearchPane').show();</script>
			</div>
			<ul class="tree-view">
				<li class="tree-view ">
					<div class="package ">autoptr
					</div>
			<ul class="tree-view">
				<li>
					<div class="module ">
						<a href="../../autoptr/common.html">common</a>
					</div>
				</li>
				<li>
					<div class="module ">
						<a href="../../autoptr/intrusive_ptr.html">intrusive_ptr</a>
					</div>
				</li>
				<li>
					<div class="module selected">
						<a href="../../autoptr/rc_ptr.html">rc_ptr</a>
					</div>
				</li>
				<li>
					<div class="module ">
						<a href="../../autoptr/shared_ptr.html">shared_ptr</a>
					</div>
				</li>
				<li>
					<div class="module ">
						<a href="../../autoptr/unique_ptr.html">unique_ptr</a>
					</div>
				</li>
			</ul>
				</li>
			</ul>
		</nav>
		<div id="main-contents">
			<h1>RcPtr.alloc - multiple declarations</h1>
			<nav class="page-nav">
				<ul>
					<li>
						<a href="#0">
							Function <code>RcPtr.alloc</code>
						</a>
					</li>
					<li>
						<a href="#1">
							Function <code>RcPtr.alloc</code>
						</a>
					</li>
				</ul>
			</nav><h2 id="0">Function RcPtr.alloc</h2><p>Constructs an object of type <code class="lang-d"><a href="../../autoptr/rc_ptr/RcPtr.ElementType.html"><span class="typ">ElementType</span></a></code> and wraps it in a <code class="lang-d"><a href="../../autoptr/rc_ptr/RcPtr.html"><span class="typ">RcPtr</span></a></code> using args as the parameter list for the constructor of <code class="lang-d"><a href="../../autoptr/rc_ptr/RcPtr.ElementType.html"><span class="typ">ElementType</span></a></code>.
</p>
			<div class="prototype">
				<code class="lang-d">
					<div class="single-prototype">
			<a href="../../autoptr/rc_ptr/RcPtr.html"><span class="typ">RcPtr</span></a>!(ElementType,.DestructorType!(.DestructorType!ElementType,DestructorType,DestructorAllocatorType!AllocatorType),ControlType) <span class="pln">alloc</span>(<span class="typ">bool</span> supportGC<span class="pln"> </span><span class="pun">= </span><span class="pln">platformSupportGC</span>, AllocatorType, Args...)
			<span class="pun">(</span>
			<br/>
			&nbsp;&nbsp;<span class="typ">AllocatorType</span> <span class="pln">a</span><span class="pun">,</span>
			<br/>
			&nbsp;&nbsp;<span class="kwd">auto ref </span><span class="typ">Args</span> <span class="pln">args</span>
			<br/>
			<span class="pun">)</span>
			<br/>
			<span class="kwd">if</span> <span class="pun">(</span><span class="pln">stateSize</span><span class="pun">!</span><span class="typ">AllocatorType </span><span class="pun">&gt;= </span><span class="lit">0 </span><span class="pun">&amp;&amp; !</span><span class="pln">isDynamicArray</span><span class="pun">!</span><span class="typ">ElementType</span><span class="pun">);</span>
					</div>
				</code>
			</div>
			<section><p>The object is constructed as if by the expression <code class="lang-d"><span class="pln">emplace</span><span class="pun">!<a href="../../autoptr/rc_ptr/RcPtr.ElementType.html"></span><span class="typ">ElementType</span></a><span class="pun">(</span><span class="pln">_payload</span><span class="pun">, </span><span class="pln">forward</span><span class="pun">!<a href="../../autoptr/rc_ptr/RcPtr.alloc.html#args"></span><span class="pln">args</span></a><span class="pun">)</span></code>, where payload is an internal pointer to storage suitable to hold an object of type <code class="lang-d"><a href="../../autoptr/rc_ptr/RcPtr.ElementType.html"><span class="typ">ElementType</span></a></code>.
            The storage is typically larger than <code class="lang-d"><span class="typ">ElementType<wbr/></span><span class="pun">.</span><span class="pln">sizeof</span></code> in order to use one allocation for both the control block and the <code class="lang-d"><a href="../../autoptr/rc_ptr/RcPtr.ElementType.html"><span class="typ">ElementType</span></a></code> object.
</p>
</section>

			<section><h3>Examples</h3>
<pre class="code"><code class="lang-d"><span class="kwd">auto <a href="../../autoptr/rc_ptr/RcPtr.alloc.html#a"></span><span class="pln">a</span></a><span class="pln"> </span><span class="pun">= </span><span class="pln">allocatorObject</span><span class="pun">(</span><span class="typ">Mallocator<wbr/></span><span class="pun">.</span><span class="pln">instance</span><span class="pun">);
{
    </span><span class="kwd">auto <a href="../../autoptr/rc_ptr/RcPtr.alloc.html#a"></span><span class="pln">a</span></a><span class="pln"> </span><span class="pun">= <a href="../../autoptr/rc_ptr/RcPtr.html"></span><span class="typ">RcPtr</span></a><span class="pun">!</span><span class="typ">long<wbr/></span><span class="pun">.</span><span class="pln">alloc</span><span class="pun">(<a href="../../autoptr/rc_ptr/RcPtr.alloc.html#a"></span><span class="pln">a</span></a><span class="pun">);
    </span><span class="kwd">assert</span><span class="pun">(</span><span class="pln">a<wbr/></span><span class="pun">.</span><span class="pln">get </span><span class="pun">== </span><span class="lit">0</span><span class="pun">);

    </span><span class="kwd">auto </span><span class="pln">b </span><span class="pun">= <a href="../../autoptr/rc_ptr/RcPtr.html"></span><span class="typ">RcPtr</span></a><span class="pun">!(</span><span class="kwd">const </span><span class="typ">long</span><span class="pun">)<wbr/>.</span><span class="pln">alloc</span><span class="pun">(<a href="../../autoptr/rc_ptr/RcPtr.alloc.html#a"></span><span class="pln">a</span></a><span class="pun">, </span><span class="lit">2</span><span class="pun">);
    </span><span class="kwd">assert</span><span class="pun">(</span><span class="pln">b<wbr/></span><span class="pun">.</span><span class="pln">get </span><span class="pun">== </span><span class="lit">2</span><span class="pun">);
}

{
    </span><span class="kwd">static struct </span><span class="typ">Struct</span><span class="pun">{
        </span><span class="typ">int </span><span class="pln">i </span><span class="pun">= </span><span class="lit">7</span><span class="pun">;

        </span><span class="kwd">this</span><span class="pun">(</span><span class="typ">int </span><span class="pln">i</span><span class="pun">)</span><span class="kwd">pure nothrow @safe @nogc</span><span class="pun">{
            </span><span class="kwd">this<wbr/></span><span class="pun">.</span><span class="pln">i </span><span class="pun">= </span><span class="pln">i</span><span class="pun">;
        }
    }

    </span><span class="kwd">auto </span><span class="pln">s1 </span><span class="pun">= <a href="../../autoptr/rc_ptr/RcPtr.html"></span><span class="typ">RcPtr</span></a><span class="pun">!</span><span class="typ">Struct<wbr/></span><span class="pun">.</span><span class="pln">alloc</span><span class="pun">(<a href="../../autoptr/rc_ptr/RcPtr.alloc.html#a"></span><span class="pln">a</span></a><span class="pun">);
    </span><span class="kwd">assert</span><span class="pun">(</span><span class="pln">s1<wbr/></span><span class="pun">.</span><span class="pln">get<wbr/></span><span class="pun">.</span><span class="pln">i </span><span class="pun">== </span><span class="lit">7</span><span class="pun">);

    </span><span class="kwd">auto </span><span class="pln">s2 </span><span class="pun">= <a href="../../autoptr/rc_ptr/RcPtr.html"></span><span class="typ">RcPtr</span></a><span class="pun">!</span><span class="typ">Struct<wbr/></span><span class="pun">.</span><span class="pln">alloc</span><span class="pun">(<a href="../../autoptr/rc_ptr/RcPtr.alloc.html#a"></span><span class="pln">a</span></a><span class="pun">, </span><span class="lit">123</span><span class="pun">);
    </span><span class="kwd">assert</span><span class="pun">(</span><span class="pln">s2<wbr/></span><span class="pun">.</span><span class="pln">get<wbr/></span><span class="pun">.</span><span class="pln">i </span><span class="pun">== </span><span class="lit">123</span><span class="pun">);
}

{
    </span><span class="kwd">static interface </span><span class="typ">Interface</span><span class="pun">{
    }
    </span><span class="kwd">static class </span><span class="typ">Class </span><span class="pun">: </span><span class="typ">Interface</span><span class="pun">{
        </span><span class="typ">int </span><span class="pln">i</span><span class="pun">;

        </span><span class="kwd">this</span><span class="pun">(</span><span class="typ">int </span><span class="pln">i</span><span class="pun">)</span><span class="kwd">pure nothrow @safe @nogc</span><span class="pun">{
            </span><span class="kwd">this<wbr/></span><span class="pun">.</span><span class="pln">i </span><span class="pun">= </span><span class="pln">i</span><span class="pun">;
        }
    }

    <a href="../../autoptr/rc_ptr/RcPtr.html"></span><span class="typ">RcPtr</span></a><span class="pun">!</span><span class="typ">Interface </span><span class="pln">x </span><span class="pun">= <a href="../../autoptr/rc_ptr/RcPtr.html"></span><span class="typ">RcPtr</span></a><span class="pun">!</span><span class="typ">Class<wbr/></span><span class="pun">.</span><span class="pln">alloc</span><span class="pun">(<a href="../../autoptr/rc_ptr/RcPtr.alloc.html#a"></span><span class="pln">a</span></a><span class="pun">, </span><span class="lit">3</span><span class="pun">);
    </span><span class="com">//assert(x.dynTo!Class.get.i == 3);
</span><span class="pun">}</span></code></pre>
</section>
<h2 id="1">Function RcPtr.alloc</h2><p>Constructs an object of array type <code class="lang-d"><a href="../../autoptr/rc_ptr/RcPtr.ElementType.html"><span class="typ">ElementType</span></a></code> including its array elements and wraps it in a <code class="lang-d"><a href="../../autoptr/rc_ptr/RcPtr.html"><span class="typ">RcPtr</span></a></code>.
</p>
			<div class="prototype">
				<code class="lang-d">
					<div class="single-prototype">
			<a href="../../autoptr/rc_ptr/RcPtr.html"><span class="typ">RcPtr</span></a>!(ElementType,.DestructorType!(.DestructorType!ElementType,DestructorType,DestructorAllocatorType!AllocatorType),ControlType) <span class="pln">alloc</span>(<span class="typ">bool</span> supportGC<span class="pln"> </span><span class="pun">= </span><span class="pln">platformSupportGC</span>, AllocatorType, Args...)
			<span class="pun">(</span>
			<br/>
			&nbsp;&nbsp;<span class="typ">AllocatorType</span> <span class="pln">a</span><span class="pun">,</span>
			<br/>
			&nbsp;&nbsp;<span class="kwd">const </span><span class="pln">size_t</span> <span class="pln">n</span><span class="pun">,</span>
			<br/>
			&nbsp;&nbsp;<span class="kwd">auto ref </span><span class="typ">Args</span> <span class="pln">args</span>
			<br/>
			<span class="pun">)</span>
			<br/>
			<span class="kwd">if</span> <span class="pun">(</span><span class="pln">stateSize</span><span class="pun">!</span><span class="typ">AllocatorType </span><span class="pun">&gt;= </span><span class="lit">0 </span><span class="pun">&amp;&amp; </span><span class="pln">isDynamicArray</span><span class="pun">!</span><span class="typ">ElementType</span><span class="pun">);</span>
					</div>
				</code>
			</div>
			<section></section>

			<section><h3>Parameters</h3>
<p>n = Array length
</p>

<p>                args = parameters for constructor for each array element.
</p>

<p>            The array elements are constructed as if by the expression <code class="lang-d"><span class="pln">emplace</span><span class="pun">!<a href="../../autoptr/rc_ptr/RcPtr.ElementType.html"></span><span class="typ">ElementType</span></a><span class="pun">(</span><span class="pln">_payload</span><span class="pun">, <a href="../../autoptr/rc_ptr/RcPtr.alloc.html#args"></span><span class="pln">args</span></a><span class="pun">)</span></code>, where payload is an internal pointer to storage suitable to hold an object of type <code class="lang-d"><a href="../../autoptr/rc_ptr/RcPtr.ElementType.html"><span class="typ">ElementType</span></a></code>.
            The storage is typically larger than <code class="lang-d"><span class="typ">ElementType<wbr/></span><span class="pun">.</span><span class="pln">sizeof </span><span class="pun">* <a href="../../autoptr/rc_ptr/RcPtr.alloc.html#n"></span><span class="pln">n</span></a></code> in order to use one allocation for both the control block and the each array element.
</p>
</section>
<section><h3>Examples</h3>
<pre class="code"><code class="lang-d"><span class="kwd">auto <a href="../../autoptr/rc_ptr/RcPtr.alloc.html#a"></span><span class="pln">a</span></a><span class="pln"> </span><span class="pun">= </span><span class="pln">allocatorObject</span><span class="pun">(</span><span class="typ">Mallocator<wbr/></span><span class="pun">.</span><span class="pln">instance</span><span class="pun">);
</span><span class="kwd">auto </span><span class="pln">arr </span><span class="pun">= <a href="../../autoptr/rc_ptr/RcPtr.html"></span><span class="typ">RcPtr</span></a><span class="pun">!(</span><span class="typ">long</span><span class="pun">[], <a href="../../autoptr/rc_ptr/RcPtr.DestructorType.html"></span><span class="typ">DestructorType</span></a><span class="pun">!(</span><span class="kwd">typeof</span><span class="pun">(<a href="../../autoptr/rc_ptr/RcPtr.alloc.html#a"></span><span class="pln">a</span></a><span class="pun">)))<wbr/>.</span><span class="pln">alloc</span><span class="pun">(<a href="../../autoptr/rc_ptr/RcPtr.alloc.html#a"></span><span class="pln">a</span></a><span class="pun">, </span><span class="lit">6</span><span class="pun">, -</span><span class="lit">1</span><span class="pun">);
</span><span class="kwd">assert</span><span class="pun">(</span><span class="pln">arr<wbr/></span><span class="pun">.</span><span class="pln">length </span><span class="pun">== </span><span class="lit">6</span><span class="pun">);
</span><span class="kwd">assert</span><span class="pun">(</span><span class="pln">arr<wbr/></span><span class="pun">.</span><span class="pln">get<wbr/></span><span class="pun">.</span><span class="pln">length </span><span class="pun">== </span><span class="lit">6</span><span class="pun">);

</span><span class="kwd">import </span><span class="pln">std<wbr/></span><span class="pun">.</span><span class="pln">algorithm </span><span class="pun">: </span><span class="pln">all</span><span class="pun">;
</span><span class="kwd">assert</span><span class="pun">(</span><span class="pln">arr<wbr/></span><span class="pun">.</span><span class="pln">get<wbr/></span><span class="pun">.</span><span class="pln">all</span><span class="pun">!(</span><span class="pln">x </span><span class="pun">=&gt; </span><span class="pln">x </span><span class="pun">== -</span><span class="lit">1</span><span class="pun">));

</span><span class="kwd">for</span><span class="pun">(</span><span class="typ">long </span><span class="pln">i </span><span class="pun">= </span><span class="lit">0</span><span class="pun">; </span><span class="pln">i </span><span class="pun">&lt; </span><span class="lit">6</span><span class="pun">; ++</span><span class="pln">i</span><span class="pun">)
    </span><span class="pln">arr<wbr/></span><span class="pun">.</span><span class="pln">get</span><span class="pun">[</span><span class="pln">i</span><span class="pun">] = </span><span class="pln">i</span><span class="pun">;

</span><span class="kwd">assert</span><span class="pun">(</span><span class="pln">arr<wbr/></span><span class="pun">.</span><span class="pln">get </span><span class="pun">== [</span><span class="lit">0</span><span class="pun">, </span><span class="lit">1</span><span class="pun">, </span><span class="lit">2</span><span class="pun">, </span><span class="lit">3</span><span class="pun">, </span><span class="lit">4</span><span class="pun">, </span><span class="lit">5</span><span class="pun">]);</span></code></pre>
</section>

			<footer>
				<table class="license-info">
					<tr>
						<th>Authors</th>
						<td>
							<p>github.com/submada/basic_string, Adam Búš
</p>

						</td>
					</tr>
					<tr>
						<th>Copyright</th>
						<td>
							
						</td>
					</tr>
					<tr>
						<th>License</th>
						<td>
							<p>www.boost.org/LICENSE_1_0.txt, Boost License 1.0.
</p>

						</td>
					</tr>
				</table>
				<p class="faint">Generated using the DDOX documentation generator</p>
			</footer>
		</div>
	</body>
</html>